//
//  ZPShareView.m
//  ZPIOSEducation
//
//  Created by mini1 on 2016/12/1.
//  Copyright © 2016年 mini1. All rights reserved.
//

#import "ZPShareView.h"

static ZPShareView  * _singleView = nil;

@interface ZPShareView ()

@end

@implementation ZPShareView

#pragma mark - <单例>
+ (instancetype)sharedSingleView {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _singleView = [[ZPShareView alloc] init];
    });
    return _singleView;
}

+ (id)allocWithZone:(struct _NSZone *)zone {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _singleView = [super allocWithZone:zone];
    });
    return _singleView;
}

- (id)copyWithZone:(NSZone *)zone{
    return _singleView;
}

- (id)mutableCopy {
    return self;
}

- (id)copy {
    return self;
}

#pragma mark - <创建view的方法抽取>
// label
-(void)setupLabel:(UILabel *)label masksToBounds:(BOOL)masksToBounds cornerRadius:(CGFloat)cornerRadius backgroundColor:(UIColor *)bgColor text:(NSString *)text textColor:(UIColor *)textColor font:(CGFloat)fontSize textAlignment:(NSTextAlignment)textAlignment {
    label.layer.masksToBounds = masksToBounds;
    label.layer.cornerRadius  = cornerRadius;
    label.backgroundColor = bgColor;
    label.text = text;
    label.textColor = textColor;
    label.font = [UIFont systemFontOfSize:fontSize];
    label.textAlignment = textAlignment;
}

// imageView
-(void)setupImageView:(UIImageView *)imageView masksToBounds:(BOOL)masksToBounds cornerRadius:(CGFloat)cornerRadius backgroundColor:(UIColor *)bgColor image:(NSString*)imageName  {
    imageView.layer.masksToBounds = masksToBounds;
    imageView.layer.cornerRadius = cornerRadius;
    imageView.backgroundColor = bgColor;
    imageView.image = [UIImage imageNamed:imageName];
}

// textField
- (void)setupTextField:(UITextField *)textField masksToBounds:(BOOL)masksToBounds cornerRadius:(CGFloat)cornerRadius backgroundColor:(UIColor *)bgColor borderStyle:(UITextBorderStyle)borderStyle textAlignment:(NSTextAlignment)textAlignment font:(CGFloat)fontSize placeholder:(NSString *)placeholder isSecureTextEntry:(BOOL)isEntry textFieldViewMode:(UITextFieldViewMode)textFieldViewMode textColor:(UIColor *)textColor keyboardType:(UIKeyboardType )type {
    textField.layer.masksToBounds = masksToBounds;
    textField.layer.cornerRadius = cornerRadius;
    textField.backgroundColor = bgColor;
    textField.borderStyle = borderStyle;
    textField.textAlignment = textAlignment;
    textField.font = [UIFont systemFontOfSize:fontSize];
    textField.placeholder = placeholder;
    textField.secureTextEntry = isEntry;
    textField.clearButtonMode = textFieldViewMode;
    textField.textColor = textColor;
    textField.keyboardType = type;
}

// button
- (void)setupButton:(UIButton *)button  backgroundColor:(UIColor *)bgColor image:(NSString*)imageName title:(NSString *)title titltColor:(UIColor *)titltColor titleFont:(CGFloat)font {
    [button setBackgroundColor:bgColor];
    [button setBackgroundImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [button setTitle:title forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:font];
    [button setTitleColor:titltColor forState:UIControlStateNormal];
}

// view
- (void)setupView:(UIView *)lineView masksToBounds:(BOOL)masksToBounds cornerRadius:(CGFloat)cornerRadius backgroundColor:(UIColor *)bgColor {
    lineView.layer.masksToBounds = masksToBounds;
    lineView.layer.cornerRadius = cornerRadius;
    lineView.backgroundColor = bgColor;
}

@end
